package com.ruoyi.project.purchase.outside.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.purchase.outside.domain.Fycgzl;
import com.ruoyi.project.purchase.outside.service.IFycgzlService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 采购指令Controller
 * 
 * @author frank
 * @date 2024-08-20
 */
@RestController
@RequestMapping("/purchase/outside/fycgzl")
public class FycgzlController extends BaseController
{
    @Autowired
    private IFycgzlService fycgzlService;

    /**
     * 查询采购指令列表
     */
    @PreAuthorize("@ss.hasPermi('purchase/outside:fycgzl:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fycgzl fycgzl)
    {
        startPage();
        List<Fycgzl> list = fycgzlService.selectFycgzlList(fycgzl);
        return getDataTable(list);
    }

    /**
     * 导出采购指令列表
     */
    @PreAuthorize("@ss.hasPermi('purchase/outside:fycgzl:export')")
    @Log(title = "采购指令", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Fycgzl fycgzl)
    {
        List<Fycgzl> list = fycgzlService.selectFycgzlList(fycgzl);
        ExcelUtil<Fycgzl> util = new ExcelUtil<Fycgzl>(Fycgzl.class);
        util.exportExcel(response, list, "采购指令数据");
    }

    /**
     * 获取采购指令详细信息
     */
    @PreAuthorize("@ss.hasPermi('purchase/outside:fycgzl:query')")
    @GetMapping(value = "/{fyCgzloid}")
    public AjaxResult getInfo(@PathVariable("fyCgzloid") String fyCgzloid)
    {
        return success(fycgzlService.selectFycgzlByFyCgzloid(fyCgzloid));
    }

    /**
     * 新增采购指令
     */
    @PreAuthorize("@ss.hasPermi('purchase/outside:fycgzl:add')")
    @Log(title = "采购指令", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fycgzl fycgzl)
    {
        return toAjax(fycgzlService.insertFycgzl(fycgzl));
    }

    /**
     * 修改采购指令
     */
    @PreAuthorize("@ss.hasPermi('purchase/outside:fycgzl:edit')")
    @Log(title = "采购指令", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fycgzl fycgzl)
    {
        return toAjax(fycgzlService.updateFycgzl(fycgzl));
    }

    /**
     * 删除采购指令
     */
    @PreAuthorize("@ss.hasPermi('purchase/outside:fycgzl:remove')")
    @Log(title = "采购指令", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fyCgzloids}")
    public AjaxResult remove(@PathVariable String[] fyCgzloids)
    {
        return toAjax(fycgzlService.deleteFycgzlByFyCgzloids(fyCgzloids));
    }
}
